package com.mlz.mlzmall.ui.activity.frag.main;


import android.app.Fragment;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.JsonRequest;
import com.google.gson.Gson;
import com.mlz.mlzmall.R;
import com.mlz.mlzmall.bean.CommentAllBean;
import com.mlz.mlzmall.bean.CommentAllBean.CommentAll.Commentall;
import com.mlz.mlzmall.bean.CustomerTag;
import com.mlz.mlzmall.bean.GetAllTagsResponse;
import com.mlz.mlzmall.ui.activity.act.main.ImagePreviewActivity;
import com.mlz.mlzmall.ui.activity.act.main.MyApplication;
import com.mlz.mlzmall.ui.activity.act.order.ConfirmOrderActivity;
import com.mlz.mlzmall.ui.activity.frag.base.BaseFragment;
import com.mlz.mlzmall.ui.dialog.ReuestDialog;
import com.mlz.mlzmall.ui.utils.mlz.ConfigInfo;
import com.mlz.mlzmall.ui.utils.mlz.URL;
import com.mlz.mlzmall.ui.utils.util.ListViewUtils;
import com.mlz.mlzmall.ui.utils.util.LogUtils;
import com.mlz.mlzmall.volley.volley.NetRequest;
import com.mlz.mlzmall.volley.volley.RequestListener;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.sina.weibo.sdk.utils.LogUtil;

import org.json.JSONException;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Pm on 2016/5/20.
 */
public class CustomerEvaluationFragment extends BaseFragment {
    boolean imageVisibility = false;

    private List<Commentall> flauntList;
    private List<Commentall> commentallList;

    private int productid;
    private LinearLayout linearLayout_all;

    private Button btn_all_comment;
    private Button btn_show;
    private ImageView img_press_down;
    private ImageView img_press_out;

    private LinearLayout ll_include_choose_goods;
    private Spinner spinner_age_all;
    private Spinner spinner_style_all;
    private Spinner spinner_clothes_all;

    //   private TextView tv_without_content;
    private RelativeLayout rl_no_data;
    private ListView lv_assess;

    private PreviewHandler previewHandler;
    String[] urlimagres;

    //评论选项数据
    public List<CustomerTag> agegrouplist;
    public List<CustomerTag> characterlist;
    public List<CustomerTag> dressstylelist;
    //适配
    ArrayAdapter<String> adapter_age, adapter_style, adapter_clo;
    //spinner选择位置
    private int spinner_age_position = 0;
    private int spinner_style_position = 0;
    private int spinner_clothes_position = 0;
    //晒单标识
    private boolean flaunt_flag = false;
    private LinearLayout ll_list_layout;

    public static CustomerEvaluationFragment newInstance(int productid) {
        CustomerEvaluationFragment gustomerEvaluationFragment = new CustomerEvaluationFragment();
        gustomerEvaluationFragment.productid = productid;

        return gustomerEvaluationFragment;

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_customer_evaluation, container, false);
        return rootView;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        linearLayout_all = (LinearLayout) getActivity().findViewById(R.id.rightImage);
        ll_list_layout = (LinearLayout) getActivity().findViewById(R.id.ll_list_layout);

        btn_all_comment = (Button) getActivity().findViewById(R.id.btn_all_comment);
        btn_show = (Button) getActivity().findViewById(R.id.btn_show);
        img_press_down = (ImageView) getActivity().findViewById(R.id.iv_press_down);
        img_press_out = (ImageView) getActivity().findViewById(R.id.iv_press_out);

        ll_include_choose_goods = (LinearLayout) getActivity().findViewById(R.id.ll_include_choose_goods);
        spinner_age_all = (Spinner) getActivity().findViewById(R.id.tv_age_all);
        spinner_style_all = (Spinner) getActivity().findViewById(R.id.tv_style_all);
        spinner_clothes_all = (Spinner) getActivity().findViewById(R.id.tv_clothes_all);
        //   tv_without_content = (TextView)getActivity().findViewById(R.id.tv_without_content);
        rl_no_data = (RelativeLayout) getActivity().findViewById(R.id.rl_no_data);
        lv_assess = (ListView) getActivity().findViewById(R.id.lv_assess);

        btn_all_comment.setOnClickListener(this);
        btn_show.setOnClickListener(this);
        img_press_out.setOnClickListener(this);
        img_press_down.setOnClickListener(this);
        previewHandler = new PreviewHandler();
        initListener();
        getDataByFlaunt();
        //  getDataByTag();
    }

    public void initListener() {
        spinner_age_all.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                spinner_age_position = agegrouplist.get(position).getCustomerTagId();
                getDataByChoose(flaunt_flag, spinner_age_position, spinner_style_position, spinner_clothes_position, 100);
                LogUtils.d(agegrouplist.get(position).getName());
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        spinner_style_all.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                spinner_style_position = characterlist.get(position).getCustomerTagId();
                getDataByChoose(flaunt_flag, spinner_age_position, spinner_style_position, spinner_clothes_position, 100);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        spinner_clothes_all.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                spinner_clothes_position = dressstylelist.get(position).getCustomerTagId();
                getDataByChoose(flaunt_flag, spinner_age_position, spinner_style_position, spinner_clothes_position, 100);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        // lv_assess.setAdapter(new MyAdapterComment());
    }

    /**
     * 获取全部评论
     */
    public void getData() {
        //     Toast.makeText(getActivity(), "ss" + productid, Toast.LENGTH_SHORT).show();
        // NetRequest.get(getActivity(), "http://app.mlzmall.com/mlzmall/api/product/review?productId=" + productid, new RequestListener() {
        getDataByChoose(flaunt_flag, 0, 0, 0, 100);
    }

    /**
     * @param imageurl
     * @param images
     * @param cout
     */
    public void imageClick(final List<String> imageurl, final ImageView[] images, int cout) {
        // imageLoader.displayImage(imageurl.get(cout), images[cout], optionss);
        ImageLoader.getInstance().displayImage(imageurl.get(cout), images[cout]);
        images[cout].setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imageVisibility = true;
                Message message = previewHandler.obtainMessage();
                urlimagres = imageurl.toArray(new String[imageurl.size()]);
                switch (v.getId()) {
                    case R.id.im_tag1:
                        message.arg1 = 0;
                        message.obj = imageurl.get(0);
                        break;
                    case R.id.im_tag2:
                        message.arg1 = 1;
                        message.obj = imageurl.get(1);
                        break;
                    case R.id.im_tag3:
                        message.arg1 = 2;
                        message.obj = imageurl.get(2);
                        break;
                    case R.id.im_tag4:
                        message.arg1 = 3;
                        message.obj = imageurl.get(3);
                        break;
                    case R.id.im_tag5:
                        message.arg1 = 4;
                        message.obj = imageurl.get(4);
                        break;
                }
                previewHandler.sendMessage(message);
            }
        });
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.btn_all_comment:
                btn_all_comment.setBackgroundResource(R.color.blue);
                btn_all_comment.setTextColor(Color.WHITE);
                btn_show.setBackgroundResource(R.drawable.register_bg);
                btn_show.setTextColor(getResources().getColor(R.color.blue));
                flaunt_flag = false;
                getDataByChoose(flaunt_flag, spinner_age_position, spinner_style_position, spinner_clothes_position, 100);
                break;
            case R.id.btn_show:
                btn_show.setBackgroundResource(R.color.blue);
                btn_show.setTextColor(Color.WHITE);
                btn_all_comment.setBackgroundResource(R.drawable.register_bg);
                btn_all_comment.setTextColor(getResources().getColor(R.color.blue));
                flaunt_flag = true;
                getDataByChoose(flaunt_flag, spinner_age_position, spinner_style_position, spinner_clothes_position, 100);
                break;
            case R.id.iv_press_out:
                LogUtils.d("R.id.iv_press_out");
                ll_include_choose_goods.setVisibility(View.VISIBLE);
                img_press_down.setVisibility(View.VISIBLE);
                img_press_out.setVisibility(View.GONE);
                spinner_age_all.setSelection(0);
                spinner_style_all.setSelection(0);
                spinner_clothes_all.setSelection(0);
                break;
            case R.id.iv_press_down:
                ll_include_choose_goods.setVisibility(View.GONE);
                img_press_down.setVisibility(View.GONE);
                img_press_out.setVisibility(View.VISIBLE);
            default:
                break;

        }
    }

    /**
     * 获取评论选项标识
     */
    private void getDataByTag() {
        //   ReuestDialog.showProgressDialog(getActivity());
   //     JsonRequest jsonRequest = new JsonObjectRequest(Request.Method.GET, "http://app.mlzmall.com/api/public/getAllTags", null, new Response.Listener<JSONObject>() {
        JsonRequest jsonRequest = new JsonObjectRequest(Request.Method.GET, URL.PUBLIC.GET_CUSTOMER_OPTION, null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject jsonObject) {
                //      ReuestDialog.dissmissProgressDialog();
                LogUtils.d("获得评论标识" + jsonObject.toString());
                Gson gson = new Gson();
                GetAllTagsResponse bean = gson.fromJson(jsonObject.toString(), GetAllTagsResponse.class);
                agegrouplist = bean.getData().get("age_group");
                dressstylelist = bean.getData().get("dress_style");
                characterlist = bean.getData().get("character");
                //      Toast.makeText(getActivity(),agegrouplist.get(0).getName(),Toast.LENGTH_SHORT).show();
                if (agegrouplist != null && agegrouplist.size() > 0) {
                    LogUtils.d("agegrouplist" + agegrouplist.toString());
                    adapter_age = new ArrayAdapter(getActivity(), R.layout.fragment_customer_evaluation_spinner_item, R.id.txtvwSpinner, getStrings("全部年龄", agegrouplist));
                    adapter_age.setDropDownViewResource(R.layout.fragment_customer_evaluation_spinner_dropdown_style);
                    spinner_age_all.setAdapter(adapter_age);

                }
                if (dressstylelist != null && dressstylelist.size() > 0) {
                    LogUtils.d("dressstylelist" + dressstylelist.toString());
                    // spinner_clothes_all.setAdapter(new CustomerTagAdapter(getActivity(), getDataByHead("全部衣着",dressstylelist), R.layout.spinner_display_style));
                    adapter_style = new ArrayAdapter(getActivity(), R.layout.fragment_customer_evaluation_spinner_item, R.id.txtvwSpinner, getStrings("全部衣着", dressstylelist));
                    adapter_style.setDropDownViewResource(R.layout.fragment_customer_evaluation_spinner_dropdown_style);
                    spinner_clothes_all.setAdapter(adapter_style);
                }
                if (characterlist != null && characterlist.size() > 0) {
                    LogUtils.d("characterlist" + characterlist.toString());
                    //   spinner_style_all.setAdapter(new CustomerTagAdapter(getActivity(), getDataByHead("全部风格",characterlist), R.layout.spinner_display_style));
                    adapter_clo = new ArrayAdapter(getActivity(), R.layout.fragment_customer_evaluation_spinner_item, R.id.txtvwSpinner, getStrings("全部风格", characterlist));
                    adapter_clo.setDropDownViewResource(R.layout.fragment_customer_evaluation_spinner_dropdown_style);
                    spinner_style_all.setAdapter(adapter_clo);

                }
                getData();


            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e("getDataByTag111", error.getMessage(), error);

            }
        }) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> map = new HashMap<String, String>();
                map.put(ConfigInfo.CHARSET, ConfigInfo.UTF8);
                map.put(ConfigInfo.COOKIE, ConfigInfo.COOKIE_KEY + sessionId);
                map.put(ConfigInfo.TYPE, ConfigInfo.TYPE_KEY);
                return map;
            }
        };

        // 设置该请求的标签
        jsonRequest.setTag("getDataByTag111");
        // 将请求添加到队列中
        ((MyApplication) getActivity().getApplication()).getRequestQueue().add(jsonRequest);
    }

    class MyAdapterComment extends BaseAdapter {
        @Override
        public int getCount() {
            return commentallList.size();//需要优化,大了会报错
        }

        @Override
        public Object getItem(int position) {
            return commentallList.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            GoodsCommentViewHolder vh;
            if (convertView == null) {
                convertView = LayoutInflater.from(getActivity()).inflate(R.layout.comment_all, null);
                vh = new GoodsCommentViewHolder();
                vh.tv_comment_content = (TextView) convertView.findViewById(R.id.tv_comment_content);
                vh.tv_comment_name = (TextView) convertView.findViewById(R.id.tv_comment_name);
                vh.iv_comment = (ImageView) convertView.findViewById(R.id.iv_comment);
                vh.iv_comment_sex = (ImageView) convertView.findViewById(R.id.iv_ommentsex);
                vh.tv_dateAdded = (TextView) convertView.findViewById(R.id.tv_dateAdded);
                vh.tv_tag_1 = (TextView) convertView.findViewById(R.id.tv_tag_1);
                vh.tv_tag_2 = (TextView) convertView.findViewById(R.id.tv_tag_2);
                vh.tv_tag_3 = (TextView) convertView.findViewById(R.id.tv_tag_3);
                vh.im_tag1 = (ImageView) convertView.findViewById(R.id.im_tag1);
                vh.im_tag2 = (ImageView) convertView.findViewById(R.id.im_tag2);
                vh.im_tag3 = (ImageView) convertView.findViewById(R.id.im_tag3);
                vh.im_tag4 = (ImageView) convertView.findViewById(R.id.im_tag4);
                vh.im_tag5 = (ImageView) convertView.findViewById(R.id.im_tag5);
                vh.layout_im = (LinearLayout) convertView.findViewById(R.id.layout_im);
                convertView.setTag(vh);
            } else {
                vh = (GoodsCommentViewHolder) convertView.getTag();
            }
            vh.tv_comment_content.setText(commentallList.get(position).getText());
            if (commentallList.get(position).getImages().size() > 0) {
                vh.layout_im.setVisibility(View.VISIBLE);
                final List<String> imageurl = commentallList.get(position).getImages();
                final ImageView[] images = {vh.im_tag1, vh.im_tag2, vh.im_tag3, vh.im_tag4, vh.im_tag5};
                if (imageurl.size() <= 5) {
                    for (int cout = 0; cout < imageurl.size(); cout++) {
                        imageClick(imageurl, images, cout);
                    }
                } else {
                    for (int i = 0; i < 5; i++) {
                        imageClick(imageurl, images, i);
                    }
                }
            }
            if (commentallList.get(position).getCustomer() != null) {
                if (commentallList.get(position).getCustomer().getAgeGroupTagName() != null) {
                    vh.tv_tag_1.setVisibility(View.VISIBLE);
                    vh.tv_tag_1.setText(commentallList.get(position).getCustomer().getAgeGroupTagName());
                }
                if (commentallList.get(position).getCustomer().getCharacterTagName() != null) {
                    vh.tv_tag_2.setVisibility(View.VISIBLE);
                    vh.tv_tag_2.setText(commentallList.get(position).getCustomer().getCharacterTagName());
                }
                if (commentallList.get(position).getCustomer().getDressStyleTagName() != null) {
                    vh.tv_tag_3.setVisibility(View.VISIBLE);
                    vh.tv_tag_3.setText(commentallList.get(position).getCustomer().getDressStyleTagName());
                }
                vh.tv_comment_name.setText(commentallList.get(position).getCustomer().getFullname());
//                    List images = commentallist.get(position).getImages();
                //          imageLoader.displayImage(commentallList.get(position).getCustomer().getPortrait(), vh.iv_comment, optionss);
                ImageLoader.getInstance().displayImage(commentallList.get(position).getCustomer().getPortrait(), vh.iv_comment);
                final int gender = commentallList.get(position).getCustomer().getGender();//获取性别图片
                switch (gender) {
                    case 1:
                        vh.iv_comment_sex.setImageResource(R.mipmap.pic_2_3_icon_male);
                        vh.iv_comment_sex.setVisibility(View.VISIBLE);

                        break;
                    case 2:
                        vh.iv_comment_sex.setImageResource(R.mipmap.pic_2_3_icon_female);
                        vh.iv_comment_sex.setVisibility(View.VISIBLE);

                        break;
                    default:
                        vh.iv_comment_sex.setVisibility(View.GONE);
                        break;
                }
            } else {
                vh.tv_comment_name.setText("name");
                //    imageLoader.displayImage("", vh.iv_comment, optionss);
                ImageLoader.getInstance().displayImage("", vh.iv_comment);
            }
            //将后台的long型时间转换为正常日期并显示
            Date dat_end = new Date(commentallList.get(position).getDateAdded());
            java.util.GregorianCalendar ge = new java.util.GregorianCalendar();
            ge.setTime(dat_end);
            SimpleDateFormat formatend = new SimpleDateFormat("yyyy-MM-dd");
            String end = formatend.format(ge.getTime());
            vh.tv_dateAdded.setText(end);

            return convertView;
        }

        class GoodsCommentViewHolder {
            TextView tv_comment_content;
            TextView tv_comment_name;
            ImageView iv_comment;
            ImageView iv_comment_sex;
            TextView tv_dateAdded;
            TextView tv_tag_1;
            TextView tv_tag_2;
            TextView tv_tag_3;
            ImageView im_tag1;
            ImageView im_tag2;
            ImageView im_tag3;
            ImageView im_tag4;
            ImageView im_tag5;
            LinearLayout layout_im;


        }
    }

    class PreviewHandler extends Handler {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            Intent intent = new Intent(getActivity(), ImagePreviewActivity.class);
            intent.putExtra("imageurl", msg.obj.toString());
            intent.putExtra("urlimages", urlimagres);
            intent.putExtra("item", msg.arg1);
            startActivity(intent);
        }
    }

    private List<CustomerTag> getDataByHead(String name, List<CustomerTag> list) {
        CustomerTag customerTag = new CustomerTag();
        customerTag.setName(name);
        list.add(0, customerTag);
        return list;
    }

    private String[] getStrings(String name, List<CustomerTag> list) {

        CustomerTag customerTag = new CustomerTag();
        customerTag.setName(name);
        list.add(0, customerTag);
        String[] str = new String[list.size()];
        for (int i = 0; list.size() - i > 0; i++) {
            str[i] = list.get(i).getName();
        }
        return str;
    }

    /**
     * 获取评论
     *
     * @param flaunt
     * @param ageGroupTagId
     * @param characterTagId
     * @param dressStyleTagId
     * @param pageSize
     */
    public void getDataByChoose(final Boolean flaunt, final int ageGroupTagId, final int characterTagId, final int dressStyleTagId, int pageSize) {
        //    ReuestDialog.showProgressDialog(getActivity());
        final StringBuffer str = new StringBuffer();
        if (flaunt != null && flaunt == true) {
            str.append("&flaunt=true");
        }
        if (ageGroupTagId != 0) {
            str.append("&ageGroupTagId=" + ageGroupTagId);
        }
        if (characterTagId != 0) {
            str.append("&characterTagId=" + characterTagId);
        }
        if (dressStyleTagId != 0) {
            str.append("&dressStyleTagId=" + dressStyleTagId);
        }
 //       JsonRequest jsonRequest = new JsonObjectRequest(Request.Method.GET, "http://app.mlzmall.com/api/product/review?productId=" + productid + str.toString(), null, new Response.Listener<JSONObject>() {
        JsonRequest jsonRequest = new JsonObjectRequest(Request.Method.GET, URL.PRODUCT.REVIEW+"?productId=" + productid + str.toString(), null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject jsonObject) {
                //    ReuestDialog.dissmissProgressDialog();
                LogUtils.d("获取全部评论" + jsonObject.toString());
                Gson gson = new Gson();
                CommentAllBean commentAllBean = gson.fromJson(jsonObject.toString(), CommentAllBean.class);
                commentallList = commentAllBean.getData().getList();  //全部评论的各种数据
                if (commentallList != null && commentallList.size() > 0) {
                    LogUtils.d("评论数量:"+commentallList.size());
                    Toast.makeText(getActivity(),"评论数量:"+commentallList.size(),Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent();
                    intent.putExtra("count",commentAllBean.getData().getSize());
                    intent.setAction("action.updateUI");
                    getActivity().sendBroadcast(intent);
                    linearLayout_all.setVisibility(View.VISIBLE);
                    ll_list_layout.setVisibility(View.VISIBLE);
                    rl_no_data.setVisibility(View.GONE);
                } else {
                    ll_list_layout.setVisibility(View.GONE);
                    rl_no_data.setVisibility(View.VISIBLE);
                }
                lv_assess.setAdapter(new MyAdapterComment());
                //  notifyAll();
                //  ListViewUtils.setListViewHeightBasedOnChildren(lv_assess, true);

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e("getDataByChoose", error.getMessage(), error);
                ll_list_layout.setVisibility(View.GONE);
                rl_no_data.setVisibility(View.VISIBLE);
            }
        }) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> map = new HashMap<String, String>();
                map.put(ConfigInfo.CHARSET, ConfigInfo.UTF8);
                map.put(ConfigInfo.COOKIE, ConfigInfo.COOKIE_KEY + sessionId);
                map.put(ConfigInfo.TYPE, ConfigInfo.TYPE_KEY);
                return map;
            }
        };

        // 设置该请求的标签
        jsonRequest.setTag("getDataByChoose");
        // 将请求添加到队列中
        ((MyApplication) getActivity().getApplication()).getRequestQueue().add(jsonRequest);
    }

    /**
     * 获取晒单数量
     */
    public void getDataByFlaunt() {
        //   ReuestDialog.showProgressDialog(getActivity());
    //    JsonRequest jsonRequest = new JsonObjectRequest(Request.Method.GET, "http://app.mlzmall.com/api/product/review?productId=" + productid + "&flaunt=true", null, new Response.Listener<JSONObject>() {
        JsonRequest jsonRequest = new JsonObjectRequest(Request.Method.GET, URL.PRODUCT.REVIEW+"?productId=" + productid + "&flaunt=true", null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject jsonObject) {
                //    ReuestDialog.dissmissProgressDialog();
                LogUtils.d("获得晒单" + jsonObject.toString());
                Gson gson = new Gson();
                CommentAllBean commentAllBean = gson.fromJson(jsonObject.toString(), CommentAllBean.class);
                flauntList = commentAllBean.getData().getList();
                if (flauntList != null && flauntList.size() > 0) {
                    btn_show.setText("晒单" + flauntList.size());
                } else {
                    btn_show.setText("晒单" + 0);
                }
                getDataByTag();


            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e("getDataByFlaunt", error.getMessage(), error);

            }
        }) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> map = new HashMap<String, String>();
                map.put(ConfigInfo.CHARSET, ConfigInfo.UTF8);
                map.put(ConfigInfo.COOKIE, ConfigInfo.COOKIE_KEY + sessionId);
                map.put(ConfigInfo.TYPE, ConfigInfo.TYPE_KEY);
                return map;
            }
        };

        // 设置该请求的标签
        jsonRequest.setTag("getDataByFlaunt");
        // 将请求添加到队列中
        ((MyApplication) getActivity().getApplication()).getRequestQueue().add(jsonRequest);
    }

}
